﻿using System;
using System.Collections.Generic;
using BasicFramework.Components;

namespace BasicFramework.Entities
{
    public interface IEntity : ICollection<IComponent>, IDisposable
    {
        /// <summary>
        /// Returns the EntityManager for the entity
        /// </summary>
        EntityManager Manager { get; }
        /// <summary>
        /// Adds a Component to the entity, if overwrite is set to true a probably existing componet will be deleted.
        /// </summary>
        void Add(IComponent component, bool overwrite);
        /// <summary>
        /// Gets the name of the Entity
        /// </summary>
        string Name { get; }
        /// <summary>
        /// Gets the Parten Entity of the current Entity
        /// </summary>
        IEntity Parent { get; }
        /// <summary>
        /// Gets the GUID of the entity
        /// </summary>
        Guid GUID { get; }
        /// <summary>
        /// Gets or sets the enabled state of the entity.
        /// </summary>
        bool Enabled { get; set; }
        /// <summary>
        /// Returns the first occurence of the specified component type
        /// </summary>
        IComponent this[Type key] { get; }
        /// <summary>
        /// Finds all components of the specified type within the Entity
        /// </summary>
        List<T> FindAll<T>() where T : IComponent;
        /// <summary>
        /// Finds the first component of the specified type within the entity
        /// </summary>
        T Find<T>() where T : IComponent;
        /// <summary>
        /// Checks if the entity contains a component of the specified type
        /// </summary>
        bool Contains<T>() where T : IComponent;
        /// <summary>
        /// Removes all components of the specified Type
        /// </summary>
        bool Remove<T>() where T : IComponent;
        /// <summary>
        /// Start is called after the Scene is started.
        /// </summary>
        void Start();
        /// <summary>
        /// Update Method, is called for every Frame
        /// </summary>
        void Update(float frame);
        /// <summary>
        /// Draw Method, is called for every Frame
        /// </summary>
        void Draw(float frame);
        /// <summary>
        /// Is called after adding the Component, to load all GraphicsContent here if needed.
        /// </summary>
        /// <param name="loadAllContent"></param>
        void LoadResources(bool loadAllContent);
        /// <summary>
        /// Is called after removing the Component from an Entity
        /// </summary>
        /// <param name="loadAllContent"></param>
        void UnloadResources(bool loadAllContent);


        event EventHandler<ComponentEventArgs> ComponentAdded;
        event EventHandler<ComponentEventArgs> ComponentRemoved;
        event EventHandler<EntityEventArgs> ParentChanged;

    }
}
